package com.mayfool.task.vo;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.Map;

/**
 * @author zhou.xu
 * @since 2024/9/1 14:23
 */
@Data
public class ResultVO<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = 1066703792086622092L;

    private Integer code;
    private Map<String, String> msg;
    private T data;

    public static <T> ResultVO<T> success(T data) {
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(200);
        resultVO.setData(data);
        return resultVO;
    }

    public static <T> ResultVO<T> fail(Map<String, String> msg) {
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(500);
        resultVO.setMsg(msg);
        return resultVO;
    }
}
